﻿// -----------------------------------------------------------------------
// <copyright file="HolidayEN.cs" company="VDC-IT" author="LTDUC">
//      Copyright (c) VDC-IT. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace VDC.VONE.ENTITIES
{
    using System;
    using System.Data.SqlClient;
    using Microsoft.ApplicationBlocks.Data;
    using VDC.COMMON;
    
    /// <summary>
    /// Class Holiday
    /// </summary>
    public class HolidayEN : EntityEN
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="HolidayEN" /> class
        /// </summary>
        public HolidayEN()
        {
            this.HolidayId = 0;
            this.DateId = 0;
            this.Descriptions = string.Empty;
        }
        
        /// <summary>
        /// Gets or sets HolidayId
        /// </summary>
        public int HolidayId { get; set; }

        /// <summary>
        /// Gets or sets Date
        /// </summary>
        public int DateId { get; set; }

        /// <summary>
        /// Gets or sets Descriptions
        /// </summary>
        public string Descriptions { get; set; }

        /// <summary>
        /// Gets Date
        /// </summary>
        public DateEN Date
        {
            get
            {
                try
                {
                    DateEN date = null;
                    SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, Constants.StorepProcedure.VOneDateGetById, this.DateId);

                    while (reader.Read())
                    {
                        date = new DateEN();

                        if (!reader.IsDBNull(0))
                        {
                            date.DateId = reader.GetInt32(0);
                        }

                        if (!reader.IsDBNull(1))
                        {
                            date.Name = reader.GetString(1);
                        }

                        if (!reader.IsDBNull(2))
                        {
                            date.Value = reader.GetInt32(2);
                        }
                    }

                    reader.Close();
                    reader.Dispose();

                    return date;
                }
                catch (SqlException ex)
                {
                    throw new Exception(ex.ToString());
                }
            }
        }
    }
}